package com.zjdt.project.mysystem.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zjdt.project.system.domain.SysUser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zjdt.framework.aspectj.lang.annotation.Log;
import com.zjdt.framework.aspectj.lang.enums.BusinessType;
import com.zjdt.project.mysystem.domain.Swipper;
import com.zjdt.project.mysystem.service.ISwipperService;
import com.zjdt.framework.web.controller.BaseController;
import com.zjdt.framework.web.domain.AjaxResult;
import com.zjdt.common.utils.poi.ExcelUtil;
import com.zjdt.framework.web.page.TableDataInfo;

/**
 * 闪屏图片Controller
 * 
 * @author dusin
 * @date 2024-07-26
 */
@RestController
@RequestMapping("/mysystem/swipper")
public class SwipperController extends BaseController
{
    @Autowired
    private ISwipperService swipperService;

    /**
     * 查询闪屏图片列表
     */
    @PreAuthorize("@ss.hasPermi('mysystem:swipper:list')")
    @GetMapping("/list")
    public TableDataInfo list(Swipper swipper)
    {
        startPage();
        List<Swipper> list = swipperService.selectSwipperList(swipper);
        return getDataTable(list);
    }

    /**
     * 导出闪屏图片列表
     */
    @PreAuthorize("@ss.hasPermi('mysystem:swipper:export')")
    @Log(title = "闪屏图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Swipper swipper)
    {
        List<Swipper> list = swipperService.selectSwipperList(swipper);
        ExcelUtil<Swipper> util = new ExcelUtil<Swipper>(Swipper.class);
        util.exportExcel(response, list, "闪屏图片数据");
    }

    /**
     * 获取闪屏图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('mysystem:swipper:query')")
    @GetMapping(value = "/{swipperId}")
    public AjaxResult getInfo(@PathVariable("swipperId") Long swipperId)
    {
        return success(swipperService.selectSwipperBySwipperId(swipperId));
    }

    /**
     * 新增闪屏图片
     */
    @PreAuthorize("@ss.hasPermi('mysystem:swipper:add')")
    @Log(title = "闪屏图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Swipper swipper)
    {
        return toAjax(swipperService.insertSwipper(swipper));
    }

    /**
     * 修改闪屏图片
     */
    @PreAuthorize("@ss.hasPermi('mysystem:swipper:edit')")
    @Log(title = "闪屏图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Swipper swipper)
    {
        return toAjax(swipperService.updateSwipper(swipper));
    }

    /**
     * 状态修改
     */
    @PreAuthorize("@ss.hasPermi('system:swipper:edit')")
    @Log(title = "轮播图片", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody Swipper swipper)
    {
        return toAjax(swipperService.updateStatus(swipper));
    }

    /**
     * 删除闪屏图片
     */
    @PreAuthorize("@ss.hasPermi('mysystem:swipper:remove')")
    @Log(title = "闪屏图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{swipperIds}")
    public AjaxResult remove(@PathVariable Long[] swipperIds)
    {
        return toAjax(swipperService.deleteSwipperBySwipperIds(swipperIds));
    }
}
